﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Framework.Infrastructure.IoC;
using Framework.Infrastructure;
using Framework.Infrastructure.Context;

namespace Framework.Services
{
    public class DbContextBaseService<TDbContext> : IDisposable where TDbContext : DbContext
    {
        protected TDbContext DbContext
        {
            get
            {
                return IoCFactory.Resolve<TDbContext>();
            }
        }

        protected void Commit()
        {
            DbContext.SaveChanges();
        }



        #region IDisposable Members

        public void Dispose()
        {
            Utility.DisposeContainerExtensions();
            DbContext.Dispose();
        }

        #endregion
    }
}
